export class Stat {
  etag!: string;
  size!: number;
  lastModified!: Date;
  retentionModal!: string;
  retentionRetainUtilDate!: Date;
  legalHold!: boolean;
  deleteMarker!: boolean;
  versionId!: string;
  contentTypeL!: string;
  userMetadata!: UserMetadata;

  constructor(data?: Partial<Stat>) {
    Object.assign(this, data);

    if (data?.lastModified != undefined) {
      this.lastModified = new Date(data.lastModified);
    }

    if (data?.retentionRetainUtilDate != undefined) {
      this.retentionRetainUtilDate = new Date(data.retentionRetainUtilDate);
    }

    if (data?.userMetadata != undefined) {
      this.userMetadata = new UserMetadata(data.userMetadata);
    }
  }
}

export class Item {
  etag!: string;
  objectName!: string;
  lastModified!: Date;
  owner!: string;
  size!: number;
  storageClass!: string;
  isLastest!: boolean;
  versionId!: string;
  isDir!: boolean;
  isDeleteMarker!: boolean;
  userMetadata!: UserMetadata;

  constructor(data?: Partial<Item>) {
    Object.assign(this, data);

    if (data?.lastModified != undefined) {
      this.lastModified = new Date(data.lastModified);
    }

    if (data?.userMetadata != undefined) {
      this.userMetadata = new UserMetadata(data.userMetadata);
    }
  }
}

export class UserMetadata {
  objectid!: string;
  bucket!: string;
  minioid!: string;
  filename!: string;
  filesize!: number;
  createdon!: Date;
  createdby!: string;
  contenttype!: string;

  constructor(data?: Partial<UserMetadata>) {
    Object.assign(this, data);

    if (data?.createdon != undefined) {
      this.createdon = new Date(data.createdon);
    }
  }
}
